package com.ckerchina.admin.ckadmin.controller.console;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ckerchina.admin.ckadmin.controller.dto.MgrResponseData;
import com.ckerchina.admin.ckadmin.dao.AgentUserDao;
import com.ckerchina.admin.ckadmin.dao.CustomerUserDao;
import com.ckerchina.admin.ckadmin.domain.AgentUser;
import com.ckerchina.admin.ckadmin.domain.CustomerUser;
import com.ckerchina.admin.ckadmin.service.UpdateService;
import com.ckerchina.admin.ckadmin.utils.Page;


@Controller
public class CustomerUserController extends AbstractConsoleController{

	@Autowired
	private CustomerUserDao customerUserDao;
	@RequestMapping("customeruser/list")
	public @ResponseBody Page<CustomerUser> list(String customer_company, int start, int limit){
		String where = "";
		Map<String, Object> params = new HashMap<String, Object>();
		if(!"".equals(customer_company)){
			where += " and customer_company = :customer_company";
			params.put("customer_company", customer_company);
		}
		
		return customerUserDao.findPage(where, params, start, limit, " order by createTime desc");
	}
	@Autowired
	UpdateService updateService;
	@RequestMapping("customeruser/add")
	public @ResponseBody MgrResponseData add(CustomerUser info){	 
		updateService.addCustomerUser(info);
		return new MgrResponseData("新增成功");
	}
	@RequestMapping("customeruser/update")
	public @ResponseBody MgrResponseData update(CustomerUser info){
		updateService.updateCustomerUser(info);
		return new MgrResponseData("修改成功");
	}
}
